home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / ussbc23.zip / DEMOS / RPDEMOFM.PAS < prev   
Pascal/Delphi Source File  |  1996-07-25  |  3KB  |  139 lines

  1. unit Rpdemofm;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, Buttons, Spin, Ssbc, ExtCtrls,
  8.   RPSSBC, RPDefine, RPBase, RPCanvas, RPrinter;
  9.  
  10. type
  11.   TfmDemo = class(TForm)
  12.     Panel: TPanel;
  13.     Label1: TLabel;
  14.     Label2: TLabel;
  15.     Label3: TLabel;
  16.     Label4: TLabel;
  17.     cbType: TComboBox;
  18.     ckBearer: TCheckBox;
  19.     ckReadable: TCheckBox;
  20.     cbOrientation: TComboBox;
  21.     edData: TEdit;
  22.     btUpdate: TBitBtn;
  23.     btClose: TBitBtn;
  24.     Panel1: TPanel;
  25.     edWidth: TEdit;
  26.     Label5: TLabel;
  27.     btPrint: TBitBtn;
  28.     FontDialog: TFontDialog;
  29.     btFont: TBitBtn;
  30.     ReportPrinter1: TReportPrinter;
  31.     RPSSBarCode: TRPSSBarCode;
  32.     procedure btUpdateClick(Sender: TObject);
  33.     procedure FormCreate(Sender: TObject);
  34.     procedure ckBearerClick(Sender: TObject);
  35.     procedure ckReadableClick(Sender: TObject);
  36.     procedure FormResize(Sender: TObject);
  37.     procedure btPrintClick(Sender: TObject);
  38.     procedure btFontClick(Sender: TObject);
  39.     procedure ReportPrinter1Print(Sender: TObject);
  40.   private
  41.     procedure RepositionCode;
  42.   public
  43.   end;
  44.  
  45. var
  46.   fmDemo: TfmDemo;
  47.  
  48. implementation
  49.  
  50. {$R *.DFM}
  51.  
  52. procedure TfmDemo.btUpdateClick(Sender: TObject);
  53. begin
  54.   with RPssBarCode do
  55.   begin
  56.     Data := edData.Text;
  57.     BarWidth := StrToFloat(edWidth.Text);
  58.     case cbType.ItemIndex of
  59.       0 : BarCodeType := bcCode128;
  60.       1 : BarCodeType := bcCode39;
  61.       2 : BarCodeType := bcEAN_13;
  62.       3 : BarCodeType := bcInt2of5;
  63.       4 : BarCodeType := bcPostnet;
  64.       5 : BarCodeType := bcUPC_A;
  65.     end;
  66.     case cbOrientation.ItemIndex of
  67.       0 : Orientation := orLeft_Right;
  68.       1 : Orientation := orRight_Left;
  69.       2 : Orientation := orTop_Bottom;
  70.       3 : Orientation := orBottom_Top;
  71.     end;
  72.     ckBearer.Checked := BearerBars;
  73.   end;
  74.   RepositionCode;
  75. end;
  76.  
  77. procedure TfmDemo.FormCreate(Sender: TObject);
  78. begin
  79.   cbType.ItemIndex := 1;
  80.   cbOrientation.ItemIndex := 0;
  81.   RepositionCode;
  82. end;
  83.  
  84. procedure TfmDemo.ckBearerClick(Sender: TObject);
  85. begin
  86.   try
  87.     RPssBarCode.BearerBars := ckBearer.Checked;
  88.   finally
  89.     ckBearer.Checked := RPssBarCode.BearerBars;
  90.   end;
  91. end;
  92.  
  93. procedure TfmDemo.ckReadableClick(Sender: TObject);
  94. begin
  95.   RPssBarCode.PrintHumanReadable := ckReadable.Checked;
  96. end;
  97.  
  98. procedure TfmDemo.RepositionCode;
  99.  
  100. begin
  101.   RPssBarCode.Left := (fmDemo.Width - RPssBarCode.Width) div 2;
  102.   RPssBarCode.Top := ((fmDemo.Height-Panel.Height) - RPssBarCode.Height) div 2;
  103. end;
  104.  
  105. procedure TfmDemo.FormResize(Sender: TObject);
  106. begin
  107.   RepositionCode;
  108. end;
  109.  
  110. procedure TfmDemo.btPrintClick(Sender: TObject);
  111. begin
  112.   ReportPrinter1.Execute;
  113.   ShowMessage('Report printed!');
  114. end;
  115.  
  116. procedure TfmDemo.btFontClick(Sender: TObject);
  117. begin
  118.   with FontDialog do
  119.   begin
  120.     Font := RPssBarcode.Font;
  121.     if Execute then
  122.       RPssBarcode.Font := Font;
  123.   end;
  124. end;
  125.  
  126. procedure TfmDemo.ReportPrinter1Print(Sender: TObject);
  127. begin
  128.   With Sender as TBaseReport do
  129.   begin
  130.     { It's this easy to print your barcode!  Specify the X and Y positions in inches.
  131.       The third parameter is the height in inches.  If you specify 0 (zero), ssBarcode will
  132.       calculate the standard height-to-width ratio for this code }
  133.  
  134.     RPSSBarCode.PrintBarCode(Sender,2.0,2.0,0.0);
  135.   end; { with }
  136. end;
  137.  
  138. end.
  139.